package pkg.andru.service;

import android.os.Parcelable;

public interface DownloadEvent extends Parcelable {

    /**
     * download event status
     * 
     * @author idiottiger
     * 
     */
    public enum Status {
        STATUS_OK, STATUS_RETRY, STATUS_NETWORK_ERROR, STATUS_STORAGE_ERROR
    }

    public enum ErrorStatus {
        MAX_RETRY_ERROR, NO_NETWORK, NETWORK_ERROR, STORAGE_ERROR
    }

    /**
     * event id
     * 
     * @return
     */
    public int eventId();

    /**
     * download method, the return is the status
     * 
     * @return
     */
    public Status onDownload();

    public interface DownloadEventListener {
        /**
         * the download event callback, the callback in the ui thread
         * 
         * @param eventId
         *            the event id
         * @param right
         *            the download finish right or not
         * @param status
         *            if the right is true, the status is null, otherwise will
         *            not null
         */
        public void onDownloadEventCallback(int eventId, boolean right, ErrorStatus status);

        /**
         * all download finished callback, run in ui thread
         */
        public void onAllDownloadFinished();
    }

}
